package com.skplanet.rade.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.google.gson.annotations.Expose;

@Entity
@Table(name = "storytag")
public class StoryTag implements Serializable{

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Expose
	private Long stid;
	
	@Column(name = "keyword")
	@Expose
	private String keyword;
	
	@Column(name = "score")
	@Expose
	private double score;
	
	@Column(name = "count")
	@Expose
	private int count;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "story_sid")
	private Story story;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "tag_tid")
	private Tag tag;
	
	public StoryTag() {
		this.score = 0;
		this.count = 0;
	}

	public StoryTag(String keyword) {
		this.score = 0;
		this.count = 0;
		this.keyword = keyword;
	}
	
	public Long getStid() {
		return stid;
	}

	public void setStid(Long stid) {
		this.stid = stid;
	}

	public String getKeyword() {
		return keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}
	
	public void addCount() {
		this.count = this.getCount() + 1;
	}

	public double getScore() {
		return score;
	}

	public void setScore(double score) {
		this.score = score;
	}

	public Story getStory() {
		return story;
	}

	public void setStory(Story story) {
		this.story = story;
	}

	public Tag getTag() {
		return tag;
	}

	public void setTag(Tag tag) {
		this.tag = tag;
	}
}
